﻿using Bystd.Geo.Geometries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Bystd.Geo.GeoParsers.Shpfile
{

    [StructLayout(LayoutKind.Sequential)]
    public class ShpPoint
    {
        public int OID;
        public Coordinate Point;
    }

    [StructLayout(LayoutKind.Sequential)]
    public class ShpPolyLine
    {
        public double[] Box = new double[4];
        public int OID;
        public int NumParts;
        public int NumPoints;
        public List<int> Parts;
        public Coordinate[] coordiantes;
    }

    [StructLayout(LayoutKind.Sequential)]
    public class ShpPolygon : ShpPolyLine
    {

    }

    [StructLayout(LayoutKind.Sequential)]
    public class ShpFile
    {
        public ShpFile()
        {

        }

        public ShpFile(ShpHeader header)
        {
            this.header = header;
        }

        public ShpHeader header { get; set; }

        public List<ShpFeature> Features { get; set; }
    }

    public class ShpFeature
    {
        public int OID { get; set; }

        public Geometry geometry { get; set; }
    }

    [StructLayout(LayoutKind.Sequential)]
    public class ShpHeader
    {
        public GeoType geometryType { get; set; }

        public int FileCode { get; set; }

        public int Version { get; set; }

        public int Length { get; set; }

        public Coordinate min { get; set; }
        public Coordinate max { get; set; }
        public Coordinate z { get; set; }

        public Coordinate m { get; set; }
    }
    
    [StructLayout(LayoutKind.Sequential)]
    public class ShxInfo
    {
        public int Length { get; set; }

        public int Version { get; set; }

        public GeoType geometryType { get; set; }

        public double xMin { get; set; }

        public double yMin { get; set; }

        public double xMax { get; set; }

        public double yMax { get; set; }

        public List<ShxBlock> Blocks;
    }

    [StructLayout(LayoutKind.Sequential)]

    public class ShxBlock
    {
        public int Offset { get; set; }

        public int Length { get; set; }
    }
}
